package com.chuangke.system.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.chuangke.common.db.page.CkPageQuery;
import com.chuangke.common.http.HttpResult;
import com.chuangke.system.entity.SysOptLog;
import com.chuangke.system.service.SysOptLogService;

@RestController
@RequestMapping("optlog")
public class SysOptLogController {

	@Autowired
	private SysOptLogService sysOptLogService;

	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/find")
	public HttpResult find(@RequestBody Map<String,Object> params) {
		return HttpResult.ok(sysOptLogService.findByCondition(new CkPageQuery(params)));
	}
	
	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/findreader")
	public HttpResult findReader(@RequestBody Map<String,Object> params) {
		return HttpResult.ok(sysOptLogService.findReadedByCondition(new CkPageQuery(params)));
	}
	
	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/findonereader")
	public HttpResult findOneReader(@RequestBody Map<String,Object> params) {
		return HttpResult.ok(sysOptLogService.findOneReadByCondition(new CkPageQuery(params)));
	}
	
	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/findprocess")
	public HttpResult findOptProcess(@RequestBody Map<String,Object> params) {
		return HttpResult.ok(sysOptLogService.findProcessByCondition(new CkPageQuery(params)));
	}

	@PreAuthorize("hasAuthority('login:action')")
	@PostMapping(value = "/save")
	public HttpResult save(@RequestBody SysOptLog sysOptLog) {
		List<SysOptLog> list = new ArrayList<>() ;
		sysOptLogService.save(list);
		return HttpResult.ok();
	}

}
